package math;

/**
 * Created by fengliejv on 2022/1/16.
 */
public class CalculateMoneyInLeetcodeBank1716 {
    //数学算一把，等差数列
    public int totalMoney(int n) {
        int weeks = n/7;
        int res = n%7;
        return 28*weeks+7*(weeks-1)*weeks/2+(2*weeks+1+res)*res/2;
    }


    //模拟
    public int totalMoney2(int n) {
        int result = 0;
        int count = 1;
        int day = 0;
        while (n-- != 0) {
            result += count + day++;
            if (day == 7) {
                day = 0;
                count++;
            }
        }
        return result;
    }


}
